<?php
/**
 * Created by PhpStorm.
 * User: Vc_JiuMou
 * Date: 2018/9/14
 * Time: 22:59
 */

    include('./lib.php');
    include('./header.html');

    if(checklogin()){
        header('Location : home.php');
    };

    $username = P('username');
    $pwd = P('password');
    $pwd2 = P('password2');


    if(!$username || !$pwd || !$pwd2){
        error('请填写完整');
    }

    if($pwd !== $pwd2){
        error('密码不一致');
    }

    $redis = connectRedis();
    if($redis->get('user:username:'.$username.':userid')){
        error('用户名已存在');
    }

  //  print_r($redis->get('user:username:'));

//通过   写入redis
    $id = $redis->incr('global:userid');
    $redis->set('user:id:'.$id.':username:',$username);
   $redis->set('user:id:'.$id.':pwd',$pwd);
    $redis->set('user:username:'.$username.':userid',$id);
    success('注册成功','./home.php');
    include('footer.html');
